import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import '@/assets/init.scss';
import {
    Button, Icon, NavBar, Swipe,Popup,
    SwipeItem, List, Circle, ActionSheet,
    Cell, NoticeBar, Lazyload, Image as VanImage,
    Slider,
} from 'vant';

const app = createApp(App);
app.use(Swipe);
app.use(SwipeItem);
app.use(NavBar);
app.use(Icon);
app.use(Button);
app.use(Circle);
app.use(ActionSheet);
app.use(Cell);
app.use(NoticeBar);
app.use(Lazyload, {
  lazyComponent: true,
});
app.use(List);
app.use(VanImage);
app.use(Popup);
app.use(Slider);


// 路由前置守卫
router.beforeEach((to, from, next) => {
    /* 路由发生变化修改页面title */
    if (to.meta.title) {
      document.title = to.meta.title
    }
    /* 控制首页头部是否出现 */
    if (to.meta.proHeaderClose){
        store.commit('handleProHeaderClose', true)
    } else {
        store.commit('handleProHeaderClose', false)
    }
    next()
});

app.use(store).use(router).mount('#app');
